package wator.model;

import java.util.Observable;

import wator.model.strategies.InertiaRandomMovementStrategy;
import wator.model.strategies.NoMovementStrategy;
import wator.model.strategies.RandomMovementStrategy;
import wator.model.strategies.WeightedForceVectorStrategy;

/**
 * This singleton class is a container for available movement strategies. If a 
 * specific strategy is used, it should be cloned from a strategy in this
 * container.
 * 
 * @see MovementStrategy
 */
final public class AvailableMovementStrategies extends Observable {
	
	private static final AvailableMovementStrategies singleton = 
			new AvailableMovementStrategies();
	
	private MovementStrategy[] strategies;
	
	/**
	 * This constructor initializes the strategy list by scanning the
	 * <code>wator.model.strategy</code> package with java's reflection API.
	 */
	protected AvailableMovementStrategies() {
		// TODO: Load them dynamically
		strategies = new MovementStrategy[] {
				new RandomMovementStrategy(),
				new InertiaRandomMovementStrategy(false),
				new InertiaRandomMovementStrategy(true),
				new NoMovementStrategy(),
				new WeightedForceVectorStrategy(false),
				new WeightedForceVectorStrategy(true)};
	}
	
	/**
	 * Get the singleton instance of <code>AvailableMovementStrategy</code>. 
	 * This is not a lazy singleton pattern implementation, so the singleton is
	 * created at program start in a static way.
	 *  
	 * @return the singleton instance of <code>AvailableMovementStrategy</code>
	 */
	public static AvailableMovementStrategies getInstance() {
		return singleton;
	}

	/**
	 * Get an unsorted array of templates for all available movement
	 * strategies.
	 * 
	 * @return an array of movement strategies
	 */
	public MovementStrategy[] getStrategies() {
		return strategies;
	}
}
